<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>连锁店管理</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../css/style.css"/>
		<link rel="stylesheet" href="../css/iconfont.css" />
		<link rel="stylesheet" href="../css/wallet.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" href="JavaScript:history.go(-1)"></a>
		    <h1 class="mui-title">连锁店管理</h1>
		    <a class="mui-pull-right add" >添加</a>
		</header>
		<div class="mui-content liansd_econtent">
			<div class="liansd_edbox">
				<!--<div class="liansd_tjbox liansd_edtbox">
					<div class="liandxq_top" id='chain_name2'>XXX店-连锁店1</div>
					<div class="liansd_ze">
						<p>门店销售总额(元)</p>
						<p class="pri" id='total_money'>0.00</p>
					</div>	
					<div class="liansd_edbtn">
						<a href="#">查看</a>
						<a href="#">修改</a>
						<a href="#">删除</a>
					</div>
				</div>-->
			</div>
			
		</div>
		<script type="text/javascript" src="../js/jquery.min.js"></script>
		<script type="text/javascript">
			$('.fjysq_memlis > li').bind('click', function(){
			    $(this).addClass('active').siblings().removeClass('active');
			});
		</script>
	</body>
</html>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/layer/layer.min.js"></script>
<script type="text/javascript" src="../js/app.js"></script>
<script>
	$(function(){
		$.ajax({
			url: APP.api_url + 'agent/chain_list',
			data: {
				token: get_token(),
				uid: getUid()
			},
			success: function(data) {
				if(data.code=200){
					var chain_list = data.data.chain_list;
					if(chain_list){
						var chain_htm='';
						for(var i =0 ;i<chain_list.length;i++){
							chain_htm = "<div class='liansd_tjbox liansd_edtbox'>"+
											"<div class='liandxq_top'>"+chain_list[i].chain_store.name+"</div>"+
											"<div class='liansd_ze'><p>门店销售总额(元)</p>"+
												"<p class='pri' id='total_money'>"+chain_list[i].total_money+"</p>"+
											"</div><div class='liansd_edbtn'>"+											
												"<a onclick=look("+chain_list[i].chain_store.id+")>查看</a>"+
												"<a onclick=up_chain_info("+chain_list[i].chain_store.id+")>修改</a>"+
												"<a onclick=del_chain("+chain_list[i].chain_store.id+")>删除</a>"+
											"</div></div>";
							$('.liansd_edbox').append(chain_htm);
						}
					}
				}
			}
		});
		
		
		//添加连锁店
		$('.add').click(function(){
			location.href = 'liansuod_add.html';
		})
	})
	
function look(chain_id){
	location.href = 'liansuod_page.html?chain_id='+chain_id;
}	
	

function up_chain_info(chain_id){
	location.href = 'liansuod_add.html?chain_id='+chain_id;
}
function del_chain(chain_id){
	
	layer.confirm('确定删除当前连锁店？', {
	  btn: ['确定','取消'] //按钮
	}, function(){
	  $.ajax({
			url: APP.api_url + 'agent/del_chain',
			data: {
				token	: get_token(),
				uid		: getUid(),
				chain_id:chain_id
			},
			success: function(data) {
				layer.msg(data.msg, {
									time: 2000
							}, function(){
				    			location.reload();
						});
			}
		});
	layer.close();
	}, function(){});
}
</script>
